package com.youlai.boot;

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;

public class Ed25519KeyGen {
    public static void main(String[] args) throws Exception {
        // 创建 Ed25519 密钥对生成器
        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("Ed25519");
        KeyPair keyPair = keyPairGenerator.generateKeyPair();

        // 获取公钥和私钥
        PublicKey publicKey = keyPair.getPublic();
        PrivateKey privateKey = keyPair.getPrivate();

        System.out.println("Public Key (Base64): " + java.util.Base64.getEncoder().encodeToString(publicKey.getEncoded()));
        System.out.println("Private Key (Base64): " + java.util.Base64.getEncoder().encodeToString(privateKey.getEncoded()));
    }
}
